package leetcode.tree;

import leetcode.tree.common.TreeNode;

/**
 * @author mazouri
 * @create 2021-05-03 22:34
 */
public class _101_isSymmetric {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return false;

        return check(root.left, root.right);
    }

    public boolean check(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;
        if (left==null||right==null) return false;
        if (left.val!=right.val) return false;
        return check(left.left, right.right)&&check(left.right, right.left);
    }
}
